package com.hcryan.djm.controller;

import com.github.pagehelper.PageInfo;
import com.hcryan.djm.pojo.model.Location;
import com.hcryan.djm.result.WebResult;
import com.hcryan.djm.service.LocationService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ryanwdj
 * @since 2025/5/5
 */
@RestController
@RequestMapping("/location")
@Slf4j
@Api("目的地")
public class LocationController {

    @Autowired
    private LocationService locationService;

    /**
     * 查询内存中匹配到的地点列表
     *
     * @param name
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/page")
    public WebResult<PageInfo<Location>> getLocationPage(@RequestParam String name,
                                                         @RequestParam(defaultValue = "1") Integer pageNum,
                                                         @RequestParam(defaultValue = "10") Integer pageSize) {

        PageInfo<Location> pageInfo = locationService.getLocationPage(name, pageNum, pageSize);
        return WebResult.success(pageInfo);
    }
}
